package com.meaningful.thinking.proxy.jdk;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

public class MyEnhancer implements InvocationHandler {

    private final Object target;

    public MyEnhancer(Object target) {
        this.target = target;
    }

    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        System.out.println("I do what i what to do, Before the world end");
        Object result = method.invoke(target, args);
        System.out.println("I do what i what to do, After the new world born");
        return result;
    }

}
